package 常见排序算法;

/**
 * @author feng
 * @Date 2021/10/24 7:44
 * 快排(挖坑填数+分治法)
 */
public class QuickBuddleSort {

    public static void sort(int[] arr, int low, int high) {
        int i, j, t, temp;
        if (low > high) {
            return;
        }

        i = low;
        j = high;
        //设置基准数
        temp = arr[low];

        while (i < j) {
            //先看右边,依次往左递减
            while (temp <= arr[j] && i < j) {
                j--;
            }
            //再看左边，依次往右增加
            while (temp>=arr[i] && i<j ){
                i++;
            }


        }


    }

    public static void main(String[] args) {
        int[] arr = {1, 10, 5, 2, 4};
        sort(arr, 0, arr.length - 1);
        for (int i : arr) {
            System.out.println("排序后==" + i);
        }

    }
}
